#define _CRT_SECURE_NO_WARNINGS 1 
#include <iostream>
#include <assert.h>
using namespace std;
namespace cgc
{
	class string
	{
	public:
		const static size_t npos;
		typedef char* iterator;
		typedef const char* const_iterator;
		iterator begin();
		iterator end();

		const_iterator begin() const;
		const_iterator end() const;

		size_t size() const;
		const char* c_str() const;

		string(const char* str = "");
		string(const string& s);
		~string();

		char operator[](size_t i);
		const char operator[](size_t i) const;

		void reserve(size_t n);
		void push_back(char ch);
		void append(const char* str);
		string& operator+=(char ch);
		string& operator+=(const char* str);

		void pop_back();
		string& insert(size_t pos, char ch);
		string& insert(size_t pos, const char* str);
		string& erase(size_t pos = 0, size_t len = npos);

		size_t find(char ch, size_t pos = 0) const;
		size_t find(const char* str, size_t pos = 0)  const;
		string substr(size_t pos, size_t len = npos) const;

		bool operator<(const string& s) const;
		bool operator<=(const string& s) const;
		bool operator>(const string& s) const;
		bool operator>=(const string& s) const;
		bool operator==(const string& s) const;
		bool operator!=(const string& s) const;
		void swap(string& s);
		string& operator=(string s);
		void clear();
	private:
		char* _str = nullptr;
		int _size = 0;
		int _capacity = 0;
	};
	ostream& operator<<(ostream& out, const string& s);
	istream& operator>>(istream& in, string& s);
	istream& getline(istream& in, string& str, char delim = '\n');
}